﻿namespace SupplyChainWeb.Service
{
    using Models;
    using SupplyChainWeb.Models.DataSet1TableAdapters;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Net;
    using System.Web.Services;
    using System.Web.Services.Protocols;

    /// <summary>
    /// SugPoDtlService 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
    // [System.Web.Script.Services.ScriptService]
    public class SugPoDtlService : WebService
    {

        private static log4net.ILog log = log4net.LogManager.GetLogger("SugPoDtlService");
        //public CookieContainer CookieContainer;
        public UserValidationSoapHeader userValidation;
        /// <summary>
        /// The HelloWorld
        /// </summary>
        /// <returns>The <see cref="string"/></returns>
         [SoapHeader("userValidation")]
        [WebMethod(Description = "登录方法，返回值用来指名是不是登录成功，并且这个值在之后的接口中用来找到相对应的服务器上的session",
            EnableSession = true)]
        public string HelloLogin()
        {
            if (userValidation == null || (userValidation != null &&( string.IsNullOrEmpty(userValidation.UserName) || string.IsNullOrEmpty(userValidation.Password))))
            {
                return "用户名及密码不能为空 ";
            }
            if (userValidation != null && E10LoginService.e10Lgoin2(userValidation.UserName,userValidation.Password, this.Session))
            {
                if ( this.Session["LoginModel"] != null)
                {
                    LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];

                     return "登入成功";
                }else
                {
                     return "登入失败";
                }
                //return "login in ";
            }
           //用户名或密码不正确

            return "Hello World";
        }

        [SoapHeader("userValidation")]
        [WebMethod(Description = "更新",
          EnableSession = true)]
        public string updateSugPoDtl2(int sugNum)
        {
            string result = "success";

            if (userValidation == null || (userValidation != null && (string.IsNullOrEmpty(userValidation.UserName) || string.IsNullOrEmpty(userValidation.Password))))
            {
                return "用户名及密码不能为空 ";
            }
            if (userValidation != null && E10LoginService.e10Lgoin2(userValidation.UserName, userValidation.Password, this.Session))
            {
                if (this.Session["LoginModel"] != null)
                {
                    LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];

                }
                else
                {
                }
            }
            if (this.Session["LoginModel"] != null)
            {
                LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];
                //if (_LoginModel.UserID.Equals(userValidation.UserName) && _LoginModel.Password.Equals(userValidation.Password))
                //{
                ServiceReference1.WebService1SoapClient c = new ServiceReference1.WebService1SoapClient();
                result = c.getDtlAndUpdate(sugNum);
                //}
                //else
                //{
                //    return "用户名或者密码不正确";
                //}
            }
            else
            {
                return "用户没有登入";
            }
            return result;
        }


        [SoapHeader("userValidation")]
        [WebMethod(Description = "更新",
          EnableSession = true)]
        public string updateSugPoDtl2a(int sugNum,int reqnum)
        {
            string result = "success";

            if (userValidation == null || (userValidation != null && (string.IsNullOrEmpty(userValidation.UserName) || string.IsNullOrEmpty(userValidation.Password))))
            {
                return "用户名及密码不能为空 ";
            }
            if (userValidation != null && E10LoginService.e10Lgoin2(userValidation.UserName, userValidation.Password, this.Session))
            {
                if (this.Session["LoginModel"] != null)
                {
                    LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];

                }
                else
                {
                }
            }
            if (this.Session["LoginModel"] != null)
            {
                LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];
                //if (_LoginModel.UserID.Equals(userValidation.UserName) && _LoginModel.Password.Equals(userValidation.Password))
                //{
                ServiceReference1.WebService1SoapClient c = new ServiceReference1.WebService1SoapClient();
                result = c.getDtlAndUpdate2a(sugNum, reqnum);
                //}
                //else
                //{
                //    return "用户名或者密码不正确";
                //}
            }
            else
            {
                return "用户没有登入";
            }
            return result;
        }

        [SoapHeader("userValidation")]
        [WebMethod(Description = "更新",
          EnableSession = true)]
        public string updateZLPONum(string vendorid, int ordernum, int orderline,int ponum,int poline)
        {
            string result = "success";

            if (userValidation == null || (userValidation != null && (string.IsNullOrEmpty(userValidation.UserName) || string.IsNullOrEmpty(userValidation.Password))))
            {
                return "用户名及密码不能为空 ";
            }
            if (userValidation != null && E10LoginService.e10Lgoin2(userValidation.UserName, userValidation.Password, this.Session))
            {
                if (this.Session["LoginModel"] != null)
                {
                    LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];

                }
                else
                {
                }
            }
            log.Error("updateZLPONum " + string.Format("{0}/{1}/{2}/{3}/", ordernum, orderline, poline, vendorid));
            if (this.Session["LoginModel"] != null)
            {
                LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];
                string sqltext = string.Format("update  EpicorData.Erp.OrderHed set PONum ={1}  where Company='{2}' and OrderNum={0}	", ordernum,ponum,vendorid);
                string sqltext2 = string.Format("update  EpicorData.Erp.OrderDtl set POLine={2}  where  Company='{3}' and OrderNum={0}	and OrderLine={1}	", ordernum, orderline,  poline, vendorid);
                log.Error("updateZLPONum sql  " + sqltext);
                log.Error("updateZLPONum sql  " + sqltext2);

                SQLHelper.ExecuteReader(SQLHelper.ConnectionString, CommandType.Text, sqltext);
                SQLHelper.ExecuteReader(SQLHelper.ConnectionString, CommandType.Text, sqltext2);
                log.Error("updateZLPONum sql  success ");
            }
            else
            {
                return "用户没有登入";
            }
            return result;
        }


        //  [SoapHeader("userValidation")]
        //[WebMethod(Description = "更新",
        //    EnableSession = true)]
        public string updateSugPoDtl(string Company,
                    global::System.Nullable<global::System.DateTime> DueDate,
                    global::System.Nullable<decimal> XRelQty,
                    global::System.Nullable<decimal> PurchasingFactor,
                    global::System.Nullable<decimal> RelQty,
                    string JobNum,
                    global::System.Nullable<int> AssemblySeq,
                    string SugType,
                    global::System.Nullable<int> JobSeq,
                    string WarehouseCode,
                    global::System.Nullable<int> PONUM,
                    global::System.Nullable<int> POLine,
                    string OpCode,
                    string FOB,
                    string ShipViaCode,
                    string TermsCode,
                    string BuyerID,
                    global::System.Nullable<int> VendorNum,
                    string PurPoint,
                    string LineDesc,
                    string IUM,
                    global::System.Nullable<decimal> UnitPrice,
                    global::System.Nullable<bool> Taxable,
                    string PUM,
                    string CostPerCode,
                    string PartNum, string VenPartNum,
                    string CommentText,
                    string ClassID,
                    string RevisionNum,
                    int SugNum,
                    string VendorID,
                    string Name,
                    global::System.Nullable<bool> Buy,
                    global::System.Nullable<global::System.DateTime> OrderByDate,
                    global::System.Nullable<decimal> DocUnitPrice,
                    global::System.Nullable<int> LeadTime,
                    global::System.Nullable<int> ReqNum,
                    global::System.Nullable<int> ReqLine,
                    string Plant,
                    global::System.Nullable<bool> CreateRFQ,
                    global::System.Nullable<bool> SourceRFQ,
                    string PurchasingFactorDirection,
                    string ShortChar01,
                    string ShortChar02,
                    string ShortChar03,
                    string ShortChar04,
                    string ShortChar05,
                    global::System.Nullable<decimal> Number01,
                    global::System.Nullable<decimal> Number02,
                    global::System.Nullable<decimal> Number03,
                    global::System.Nullable<decimal> Number04,
                    global::System.Nullable<decimal> Number05,
                    global::System.Nullable<global::System.DateTime> Date01,
                    global::System.Nullable<global::System.DateTime> Date02,
                    global::System.Nullable<global::System.DateTime> Date03,
                    global::System.Nullable<global::System.DateTime> Date04,
                    global::System.Nullable<global::System.DateTime> Date05,
                    global::System.Nullable<bool> CheckBox01,
                    global::System.Nullable<bool> CheckBox02,
                    global::System.Nullable<bool> CheckBox03,
                    global::System.Nullable<bool> CheckBox04,
                    global::System.Nullable<bool> CheckBox05,
                    string Character01,
                    string Character02,
                    string Character03,
                    string Character04,
                    string Character05,
                    string Character06,
                    string Character07,
                    string Character08,
                    string Character09,
                    string Character10,
                    global::System.Nullable<int> OrderNum,
                    global::System.Nullable<int> OrderLine,
                    global::System.Nullable<int> OrderRelNum,
                    global::System.Nullable<bool> DropShip,
                    global::System.Nullable<int> MfgNum,
                    string MfgPartNum,
                    string ShipToNum,
                    global::System.Nullable<int> SoldToNum,
                    global::System.Nullable<int> BitFlag,
                    global::System.Nullable<int> ShpConNum,
                    global::System.Nullable<int> ShipToCustNum,
                    string ComplianceMsg,
                    global::System.Nullable<bool> PORelOpen,
                    string SugReason,
                    string ABCCode)
        {
             string result = "success";
            if (userValidation == null || (userValidation != null && (string.IsNullOrEmpty(userValidation.UserName) || string.IsNullOrEmpty(userValidation.Password))))
            {
                return "用户名及密码不能为空 ";
            }
            if (userValidation != null && E10LoginService.e10Lgoin2(userValidation.UserName, userValidation.Password, this.Session))
            {
                if (this.Session["LoginModel"] != null)
                {
                    LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];

                }
                else
                {
                }
            }
            if (this.Session["LoginModel"] != null)
            {
                LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];
                //if (_LoginModel.UserID.Equals(userValidation.UserName) && _LoginModel.Password.Equals(userValidation.Password))
                //{


           // if (userValidation != null && E10LoginService.e10Lgoin(userValidation.UserName, userValidation.Password, null))
            

                SugPoDtlTableAdapter sugpoada = new SugPoDtlTableAdapter();
                sugpoada.Update(
                    DueDate,
                    XRelQty,
                    PurchasingFactor,
                    RelQty,
                    JobNum,
                    AssemblySeq,
                    SugType,
                    JobSeq,
                    WarehouseCode,
                    PONUM,
                    POLine,
                    OpCode,
                    FOB,
                    ShipViaCode,
                    TermsCode,
                    BuyerID,
                    VendorNum,
                    PurPoint,
                    LineDesc,
                    IUM,
                    UnitPrice,
                    Taxable,
                    PUM,
                    CostPerCode,
                    PartNum,
                    VenPartNum,
                    CommentText,
                    ClassID,
                    RevisionNum,
                   
                    VendorID,
                    Name,
                    Buy,
                    OrderByDate,
                    DocUnitPrice,
                    LeadTime,
                    ReqNum,
                    ReqLine,
                    Plant,
                    CreateRFQ,
                    SourceRFQ,
                    PurchasingFactorDirection,
                    ShortChar01,
                    ShortChar02,
                    ShortChar03,
                    ShortChar04,
                    ShortChar05,
                    Number01,
                    Number02,
                    Number03,
                    Number04,
                    Number05,
                    Date01,
                    Date02,
                    Date03,
                    Date04,
                    Date05,
                    CheckBox01,
                    CheckBox02,
                    CheckBox03,
                    false,//CheckBox04
                    CheckBox05,
                    Character01,
                    Character02,
                    Character03,
                    Character04,
                    Character05,
                    Character06,
                    Character07,
                    Character08,
                    Character09,
                    Character10,
                    OrderNum,
                    OrderLine,
                    OrderRelNum,
                    DropShip,
                    MfgNum,
                    MfgPartNum,
                    ShipToNum,
                    SoldToNum,
                    BitFlag,
                    ShpConNum,
                    ShipToCustNum,
                    ComplianceMsg,
                    PORelOpen,
                    SugReason,
                    ABCCode,
                    Company,
                    SugNum
                    );
                //}
                //else
                //{
                //    return "用户名或者密码不正确";
                //}
            }
            else
            {
                return "用户没有登入";
            }

            return result;
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="Company">供应商ID</param>
        /// <param name="SugNum">SugNum</param>
        /// <returns></returns>
        [WebMethod(Description = "删除",
            EnableSession = true)]
        public string delSugPodtl(string Company,int SugNum)
        {
            string result = "success";
            if (userValidation == null || (userValidation != null && (string.IsNullOrEmpty(userValidation.UserName) || string.IsNullOrEmpty(userValidation.Password))))
            {
                return "用户名及密码不能为空 ";
            }
            if (userValidation != null && E10LoginService.e10Lgoin2(userValidation.UserName, userValidation.Password, this.Session))
            {
                if (this.Session["LoginModel"] != null)
                {
                    LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];

                }
                else
                {
                }
            }
            if (this.Session["LoginModel"] != null)
            {
                LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];
                //if (_LoginModel.UserID.Equals(userValidation.UserName) && _LoginModel.Password.Equals(userValidation.Password))
                //{

                    SugPoDtlTableAdapter sugpoada = new SugPoDtlTableAdapter();
                    sugpoada.Delete(Company, SugNum);
                //}
                //else
                //{
                //    return "用户名或者密码不正确";
                //}
            }
            else
            {
                return "用户没有登入";
            }
            return result;
        }

        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="sugNum">sugNum</param>
        /// <returns></returns>
        [SoapHeader("userValidation")]
        [WebMethod(Description = "增加2",
          EnableSession = true)]
        public string addSugPODtl2(int sugNum)
        {
            string result = "success";

            if (userValidation == null || (userValidation != null && (string.IsNullOrEmpty(userValidation.UserName) || string.IsNullOrEmpty(userValidation.Password))))
            {
                return "用户名及密码不能为空 ";
            }
            if (userValidation != null && E10LoginService.e10Lgoin2(userValidation.UserName, userValidation.Password, this.Session))
            {
                if (this.Session["LoginModel"] != null)
                {
                    LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];

                }
                else
                {
                }
            }
            if (this.Session["LoginModel"] != null)
            {
                LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];
                //if (_LoginModel.UserID.Equals(userValidation.UserName) && _LoginModel.Password.Equals(userValidation.Password))
                //{
                    ServiceReference1.WebService1SoapClient c = new ServiceReference1.WebService1SoapClient();
                    result = c.getDtlAndAdd(sugNum);
                //}
                //else
                //{
                //    return "用户名或者密码不正确";
                //}
            }
            else
            {
                return "用户没有登入";
            }
            return result;
        }

        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="sugNum">sugNum</param>
        /// <returns></returns>
        [SoapHeader("userValidation")]
        [WebMethod(Description = "增加2",
          EnableSession = true)]
        public string addSugPODtl2a(int sugNum,int reqnum)
        {
            string result = "success";

            if (userValidation == null || (userValidation != null && (string.IsNullOrEmpty(userValidation.UserName) || string.IsNullOrEmpty(userValidation.Password))))
            {
                return "用户名及密码不能为空 ";
            }
            if (userValidation != null && E10LoginService.e10Lgoin2(userValidation.UserName, userValidation.Password, this.Session))
            {
                if (this.Session["LoginModel"] != null)
                {
                    LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];

                }
                else
                {
                }
            }
            if (this.Session["LoginModel"] != null)
            {
                LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];
                //if (_LoginModel.UserID.Equals(userValidation.UserName) && _LoginModel.Password.Equals(userValidation.Password))
                //{
                ServiceReference1.WebService1SoapClient c = new ServiceReference1.WebService1SoapClient();
                result = c.getDtlAndAdd2a(sugNum,reqnum);
                //}
                //else
                //{
                //    return "用户名或者密码不正确";
                //}
            }
            else
            {
                return "用户没有登入";
            }
            return result;
        }

        /// <summary>
        /// The addSugPoDtl
        /// </summary>
        /// <param name="Company">The Company<see cref="string"/></param>
        /// <param name="DueDate">The DueDate<see cref="global::System.Nullable{global::System.DateTime}"/></param>
        /// <param name="XRelQty">The XRelQty<see cref="global::System.Nullable{decimal}"/></param>
        /// <param name="PurchasingFactor">The PurchasingFactor<see cref="global::System.Nullable{decimal}"/></param>
        /// <param name="RelQty">The RelQty<see cref="global::System.Nullable{decimal}"/></param>
        /// <param name="JobNum">The JobNum<see cref="string"/></param>
        /// <param name="AssemblySeq">The AssemblySeq<see cref="global::System.Nullable{int}"/></param>
        /// <param name="SugType">The SugType<see cref="string"/></param>
        /// <param name="JobSeq">The JobSeq<see cref="global::System.Nullable{int}"/></param>
        /// <param name="WarehouseCode">The WarehouseCode<see cref="string"/></param>
        /// <param name="PONUM">The PONUM<see cref="global::System.Nullable{int}"/></param>
        /// <param name="POLine">The POLine<see cref="global::System.Nullable{int}"/></param>
        /// <param name="OpCode">The OpCode<see cref="string"/></param>
        /// <param name="FOB">The FOB<see cref="string"/></param>
        /// <param name="ShipViaCode">The ShipViaCode<see cref="string"/></param>
        /// <param name="TermsCode">The TermsCode<see cref="string"/></param>
        /// <param name="BuyerID">The BuyerID<see cref="string"/></param>
        /// <param name="VendorNum">The VendorNum<see cref="global::System.Nullable{int}"/></param>
        /// <param name="PurPoint">The PurPoint<see cref="string"/></param>
        /// <param name="LineDesc">The LineDesc<see cref="string"/></param>
        /// <param name="IUM">The IUM<see cref="string"/></param>
        /// <param name="UnitPrice">The UnitPrice<see cref="global::System.Nullable{decimal}"/></param>
        /// <param name="Taxable">The Taxable<see cref="global::System.Nullable{bool}"/></param>
        /// <param name="PUM">The PUM<see cref="string"/></param>
        /// <param name="CostPerCode">The CostPerCode<see cref="string"/></param>
        /// <param name="PartNum">The PartNum<see cref="string"/></param>
        /// <param name="VenPartNum">The VenPartNum<see cref="string"/></param>
        /// <param name="CommentText">The CommentText<see cref="string"/></param>
        /// <param name="ClassID">The ClassID<see cref="string"/></param>
        /// <param name="RevisionNum">The RevisionNum<see cref="string"/></param>
        /// <param name="SugNum">The SugNum<see cref="int"/></param>
        /// <param name="VendorID">The VendorID<see cref="string"/></param>
        /// <param name="Name">The Name<see cref="string"/></param>
        /// <param name="Buy">The Buy<see cref="global::System.Nullable{bool}"/></param>
        /// <param name="OrderByDate">The OrderByDate<see cref="global::System.Nullable{global::System.DateTime}"/></param>
        /// <param name="DocUnitPrice">The DocUnitPrice<see cref="global::System.Nullable{decimal}"/></param>
        /// <param name="LeadTime">The LeadTime<see cref="global::System.Nullable{int}"/></param>
        /// <param name="ReqNum">The ReqNum<see cref="global::System.Nullable{int}"/></param>
        /// <param name="ReqLine">The ReqLine<see cref="global::System.Nullable{int}"/></param>
        /// <param name="Plant">The Plant<see cref="string"/></param>
        /// <param name="CreateRFQ">The CreateRFQ<see cref="global::System.Nullable{bool}"/></param>
        /// <param name="SourceRFQ">The SourceRFQ<see cref="global::System.Nullable{bool}"/></param>
        /// <param name="PurchasingFactorDirection">The PurchasingFactorDirection<see cref="string"/></param>
        /// <param name="ShortChar01">The ShortChar01<see cref="string"/></param>
        /// <param name="ShortChar02">The ShortChar02<see cref="string"/></param>
        /// <param name="ShortChar03">The ShortChar03<see cref="string"/></param>
        /// <param name="ShortChar04">The ShortChar04<see cref="string"/></param>
        /// <param name="ShortChar05">The ShortChar05<see cref="string"/></param>
        /// <param name="Number01">The Number01<see cref="global::System.Nullable{decimal}"/></param>
        /// <param name="Number02">The Number02<see cref="global::System.Nullable{decimal}"/></param>
        /// <param name="Number03">The Number03<see cref="global::System.Nullable{decimal}"/></param>
        /// <param name="Number04">The Number04<see cref="global::System.Nullable{decimal}"/></param>
        /// <param name="Number05">The Number05<see cref="global::System.Nullable{decimal}"/></param>
        /// <param name="Date01">The Date01<see cref="global::System.Nullable{global::System.DateTime}"/></param>
        /// <param name="Date02">The Date02<see cref="global::System.Nullable{global::System.DateTime}"/></param>
        /// <param name="Date03">The Date03<see cref="global::System.Nullable{global::System.DateTime}"/></param>
        /// <param name="Date04">The Date04<see cref="global::System.Nullable{global::System.DateTime}"/></param>
        /// <param name="Date05">The Date05<see cref="global::System.Nullable{global::System.DateTime}"/></param>
        /// <param name="CheckBox01">The CheckBox01<see cref="global::System.Nullable{bool}"/></param>
        /// <param name="CheckBox02">The CheckBox02<see cref="global::System.Nullable{bool}"/></param>
        /// <param name="CheckBox03">The CheckBox03<see cref="global::System.Nullable{bool}"/></param>
        /// <param name="CheckBox04">The CheckBox04<see cref="global::System.Nullable{bool}"/></param>
        /// <param name="CheckBox05">The CheckBox05<see cref="global::System.Nullable{bool}"/></param>
        /// <param name="Character01">The Character01<see cref="string"/></param>
        /// <param name="Character02">The Character02<see cref="string"/></param>
        /// <param name="Character03">The Character03<see cref="string"/></param>
        /// <param name="Character04">The Character04<see cref="string"/></param>
        /// <param name="Character05">The Character05<see cref="string"/></param>
        /// <param name="Character06">The Character06<see cref="string"/></param>
        /// <param name="Character07">The Character07<see cref="string"/></param>
        /// <param name="Character08">The Character08<see cref="string"/></param>
        /// <param name="Character09">The Character09<see cref="string"/></param>
        /// <param name="Character10">The Character10<see cref="string"/></param>
        /// <param name="OrderNum">The OrderNum<see cref="global::System.Nullable{int}"/></param>
        /// <param name="OrderLine">The OrderLine<see cref="global::System.Nullable{int}"/></param>
        /// <param name="OrderRelNum">The OrderRelNum<see cref="global::System.Nullable{int}"/></param>
        /// <param name="DropShip">The DropShip<see cref="global::System.Nullable{bool}"/></param>
        /// <param name="MfgNum">The MfgNum<see cref="global::System.Nullable{int}"/></param>
        /// <param name="MfgPartNum">The MfgPartNum<see cref="string"/></param>
        /// <param name="ShipToNum">The ShipToNum<see cref="string"/></param>
        /// <param name="SoldToNum">The SoldToNum<see cref="global::System.Nullable{int}"/></param>
        /// <param name="BitFlag">The BitFlag<see cref="global::System.Nullable{int}"/></param>
        /// <param name="ShpConNum">The ShpConNum<see cref="global::System.Nullable{int}"/></param>
        /// <param name="ShipToCustNum">The ShipToCustNum<see cref="global::System.Nullable{int}"/></param>
        /// <param name="ComplianceMsg">The ComplianceMsg<see cref="string"/></param>
        /// <param name="PORelOpen">The PORelOpen<see cref="global::System.Nullable{bool}"/></param>
        /// <param name="SugReason">The SugReason<see cref="string"/></param>
        /// <param name="ABCCode">The ABCCode<see cref="string"/></param>
        /// <returns>The <see cref="string"/></returns>
        [SoapHeader("userValidation")]
        //[WebMethod(Description = "添加建议",
        //    EnableSession = true)]
        public string addSugPoDtl(string Company,
                  global::System.Nullable<global::System.DateTime> DueDate,
                  global::System.Nullable<decimal> XRelQty,
                  global::System.Nullable<decimal> PurchasingFactor,
                  global::System.Nullable<decimal> RelQty,
                  string JobNum,
                  global::System.Nullable<int> AssemblySeq,
                  string SugType,
                  global::System.Nullable<int> JobSeq,
                  string WarehouseCode,
                  global::System.Nullable<int> PONUM,
                  global::System.Nullable<int> POLine,
                  string OpCode,
                  string FOB,
                  string ShipViaCode,
                  string TermsCode,
                  string BuyerID,
                  global::System.Nullable<int> VendorNum,
                  string PurPoint,
                  string LineDesc,
                  string IUM,
                  global::System.Nullable<decimal> UnitPrice,
                  global::System.Nullable<bool> Taxable,
                  string PUM,
                  string CostPerCode,
                  string PartNum, string VenPartNum,
                  string CommentText,
                  string ClassID,
                  string RevisionNum,
                  int SugNum,
                  string VendorID,
                  string Name,
                  global::System.Nullable<bool> Buy,
                  global::System.Nullable<global::System.DateTime> OrderByDate,
                  global::System.Nullable<decimal> DocUnitPrice,
                  global::System.Nullable<int> LeadTime,
                  global::System.Nullable<int> ReqNum,
                  global::System.Nullable<int> ReqLine,
                  string Plant,
                  global::System.Nullable<bool> CreateRFQ,
                  global::System.Nullable<bool> SourceRFQ,
                  string PurchasingFactorDirection,
                  string ShortChar01,
                  string ShortChar02,
                  string ShortChar03,
                  string ShortChar04,
                  string ShortChar05,
                  global::System.Nullable<decimal> Number01,
                  global::System.Nullable<decimal> Number02,
                  global::System.Nullable<decimal> Number03,
                  global::System.Nullable<decimal> Number04,
                  global::System.Nullable<decimal> Number05,
                  global::System.Nullable<global::System.DateTime> Date01,
                  global::System.Nullable<global::System.DateTime> Date02,
                  global::System.Nullable<global::System.DateTime> Date03,
                  global::System.Nullable<global::System.DateTime> Date04,
                  global::System.Nullable<global::System.DateTime> Date05,
                  global::System.Nullable<bool> CheckBox01,
                  global::System.Nullable<bool> CheckBox02,
                  global::System.Nullable<bool> CheckBox03,
                  global::System.Nullable<bool> CheckBox04,
                  global::System.Nullable<bool> CheckBox05,
                  string Character01,
                  string Character02,
                  string Character03,
                  string Character04,
                  string Character05,
                  string Character06,
                  string Character07,
                  string Character08,
                  string Character09,
                  string Character10,
                  global::System.Nullable<int> OrderNum,
                  global::System.Nullable<int> OrderLine,
                  global::System.Nullable<int> OrderRelNum,
                  global::System.Nullable<bool> DropShip,
                  global::System.Nullable<int> MfgNum,
                  string MfgPartNum,
                  string ShipToNum,
                  global::System.Nullable<int> SoldToNum,
                  global::System.Nullable<int> BitFlag,
                  global::System.Nullable<int> ShpConNum,
                  global::System.Nullable<int> ShipToCustNum,
                  string ComplianceMsg,
                  global::System.Nullable<bool> PORelOpen,
                  string SugReason,
                  string ABCCode)
        {
            string result = "success";
            if (userValidation == null || (userValidation != null && (string.IsNullOrEmpty(userValidation.UserName) || string.IsNullOrEmpty(userValidation.Password))))
            {
                return "用户名及密码不能为空 ";
            }
            if (userValidation != null && E10LoginService.e10Lgoin2(userValidation.UserName, userValidation.Password, this.Session))
            {
                if (this.Session["LoginModel"] != null)
                {
                    LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];

                }
                else
                {
                }
            }
            if (this.Session["LoginModel"] != null)
            {
                LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];
                if (_LoginModel.UserID.Equals(userValidation.UserName) && _LoginModel.Password.Equals(userValidation.Password))
                {



                    //if (userValidation != null && E10LoginService.e10Lgoin(userValidation.UserName, userValidation.Password, null))


                    SugPoDtlTableAdapter sugpoada = new SugPoDtlTableAdapter();
                    sugpoada.Insert(Company,
                        DueDate,
                        XRelQty,
                        PurchasingFactor,
                        RelQty,
                        JobNum,
                        AssemblySeq,
                        SugType,
                        JobSeq,
                        WarehouseCode,
                        PONUM,
                        POLine,
                        OpCode,
                        FOB,
                        ShipViaCode,
                        TermsCode,
                        BuyerID,
                        VendorNum,
                        PurPoint,
                        LineDesc,
                        IUM,
                        UnitPrice,
                        Taxable,
                        PUM,
                        CostPerCode,
                        PartNum,
                        VenPartNum,
                        CommentText,
                        ClassID,
                        RevisionNum,
                        SugNum,
                        VendorID,
                        Name,
                        Buy,
                        OrderByDate,
                        DocUnitPrice,
                        LeadTime,
                        ReqNum,
                        ReqLine,
                        Plant,
                        CreateRFQ,
                        SourceRFQ,
                        PurchasingFactorDirection,
                        ShortChar01,
                        ShortChar02,
                        ShortChar03,
                        ShortChar04,
                        ShortChar05,
                        Number01,
                        Number02,
                        Number03,
                        Number04,
                        Number05,
                        Date01,
                        Date02,
                        Date03,
                        Date04,
                        Date05,
                        CheckBox01,
                        CheckBox02,
                        CheckBox03,
                        false,// CheckBox04,
                        CheckBox05,
                        Character01,
                        Character02,
                        Character03,
                        Character04,
                        Character05,
                        Character06,
                        Character07,
                        Character08,
                        Character09,
                        Character10,
                        OrderNum,
                        OrderLine,
                        OrderRelNum,
                        DropShip,
                        MfgNum,
                        MfgPartNum,
                        ShipToNum,
                        SoldToNum,
                        BitFlag,
                        ShpConNum,
                        ShipToCustNum,
                        ComplianceMsg,
                        PORelOpen,
                        SugReason,
                        ABCCode
                        );
                }
                else
                {
                    return "用户名或者密码不正确";
                }
            }
            else
            {
                return "用户没有登入";
            }

            return result;
        }

        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="sugNum">sugNum</param>
        /// <returns></returns>
        //[WebMethod(Description = "增加3",
        //  EnableSession = true)]
        public string addSugPODtl3(SugPoDtl sugPoDtl)
        {
            string result = "success";

            if (userValidation == null || (userValidation != null && (string.IsNullOrEmpty(userValidation.UserName) || string.IsNullOrEmpty(userValidation.Password))))
            {
                return "用户名及密码不能为空 ";
            }
            if (this.Session["LoginModel"] != null)
            {
                LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];
                if (_LoginModel.UserID.Equals(userValidation.UserName) && _LoginModel.Password.Equals(userValidation.Password))
                {
                    SCMDataProvider.DB.SugPoDtl.InsertOnSubmit(sugPoDtl);
                    SCMDataProvider.DB.SubmitChanges();

                }
                else
                {
                    return "用户名或者密码不正确";
                }
            }
            else
            {
                return "用户没有登入";
            }
            return result;
        }

        /// <summary>
        /// 获取供应商建议数据
        /// </summary>
        /// <param name="VendorID">sugNum</param>
        /// <returns></returns>
        [SoapHeader("userValidation")]
        [WebMethod(Description = "获取供应商建议数据",
          EnableSession = true)]
        public DataSet getVendorOrder(string VendorID)
        {
            DataSet ds = new DataSet();
            ds.Clear();
            if (userValidation == null || (userValidation != null && (string.IsNullOrEmpty(userValidation.UserName) || string.IsNullOrEmpty(userValidation.Password))))
            {
                return null;
            }
            if (userValidation != null && E10LoginService.e10Lgoin2(userValidation.UserName, userValidation.Password, this.Session))
            {
                if (this.Session["LoginModel"] != null)
                {
                    LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];

                }
                else
                {
                }
            }
            if (this.Session["LoginModel"] != null)
            {
                LoginModel _LoginModel = (LoginModel)this.Session["LoginModel"];
                var orderquery = SCMDataProvider.GetSugPoDtlHis2(VendorID);
                
                List<SugPoDtl> list = orderquery.ToList<SugPoDtl>();
                //DataTable dt = list.ToDataTable<SugPoDtl>(a => new object[] { list });
                DataTable dt = new DataTable();
                if (list.Count > 0)
                {
                    SugPoDtl sd = list[0];
                    //dt.Columns.Add(new DataColumn("SugNum", sd.SugNum.GetType()));
                    dt.Columns.Add("VendorID", sd.VendorID.GetType());
                    dt.Columns.Add("BuyerID", sd.BuyerID.GetType());
                    dt.Columns.Add("SugNum", sd.SugNum.GetType());
                    dt.Columns.Add("PartNum", sd.PartNum.GetType());
                    dt.Columns.Add("RevisionNum", sd.RevisionNum.GetType());
                    dt.Columns.Add("LineDesc", sd.LineDesc.GetType());
                    dt.Columns.Add("UnitPrice", sd.UnitPrice.GetType());
                    dt.Columns.Add("XRelQty", sd.XRelQty.GetType());

                    dt.Columns.Add("IUM", sd.IUM.GetType());
                    dt.Columns.Add("OrderByDate", sd.OrderByDate.GetType());
                    dt.Columns.Add("DueDate", sd.DueDate.GetType());

                    dt.Columns.Add("CommentText", sd.CommentText.GetType());
                    dt.Columns.Add("CheckBox05", sd.CheckBox05.GetType());
                    dt.Columns.Add("ReqNum", sd.ReqNum.GetType());
                    foreach (SugPoDtl s in list)
                    {
                        DataRow row = dt.NewRow();
                        row["VendorID"] = s.VendorID;
                        row["BuyerID"] = s.BuyerID;
                        row["SugNum"] = s.SugNum;
                        row["PartNum"] = s.PartNum;
                        row["RevisionNum"] = s.RevisionNum;
                        row["LineDesc"] = s.LineDesc;
                        row["UnitPrice"] = s.UnitPrice;
                        row["XRelQty"] = s.XRelQty;

                        row["IUM"] = s.IUM;
                        row["OrderByDate"] = s.OrderByDate;
                        row["DueDate"] = s.DueDate;

                        row["CommentText"] = s.CommentText;
                        row["CheckBox05"] = s.CheckBox05;
                        row["ReqNum"] = s.ReqNum;
                        dt.Rows.Add(row);
                    }
                    dt.TableName = "Order";
                    ds.Tables.Add(dt);
                }
            }
            else
            {
                return null;
            }

            return ds;
        }


        [WebMethod(Description = "获取供应商建议数据",
          EnableSession = true)]
        public DataSet getVendorOrder2(string VendorID)
        {
            DataSet ds = new DataSet();
            ds.Clear();
                var orderquery = SCMDataProvider.GetSugPoDtlHis2(VendorID);

                List<SugPoDtl> list = orderquery.ToList<SugPoDtl>();
                //DataTable dt = list.ToDataTable<SugPoDtl>(a => new object[] { list });
                DataTable dt = new DataTable();
            if (list.Count>0)
            {
                SugPoDtl sd = list[0];
                //dt.Columns.Add(new DataColumn("SugNum", sd.SugNum.GetType()));
                dt.Columns.Add("VendorID", sd.VendorID.GetType());
                dt.Columns.Add("BuyerID", sd.BuyerID.GetType());
                dt.Columns.Add("SugNum", sd.SugNum.GetType());
                dt.Columns.Add("PartNum", sd.PartNum.GetType());
                dt.Columns.Add("RevisionNum", sd.RevisionNum.GetType());
                dt.Columns.Add("LineDesc", sd.LineDesc.GetType());
                dt.Columns.Add("UnitPrice", sd.UnitPrice.GetType());
                dt.Columns.Add("XRelQty", sd.XRelQty.GetType());

                dt.Columns.Add("IUM", sd.IUM.GetType());
                dt.Columns.Add("OrderByDate", sd.OrderByDate.GetType());
                dt.Columns.Add("DueDate", sd.DueDate.GetType());

                dt.Columns.Add("CommentText", sd.CommentText.GetType());
                dt.Columns.Add("CheckBox05", sd.CheckBox05.GetType());
                foreach (SugPoDtl s in list)
                {
                    DataRow row = dt.NewRow();
                    row["VendorID"] = s.VendorID;
                    row["BuyerID"] = s.BuyerID;
                    row["SugNum"] = s.SugNum;
                    row["PartNum"] = s.PartNum;
                    row["RevisionNum"] = s.RevisionNum;
                    row["LineDesc"] = s.LineDesc;
                    row["UnitPrice"] = s.UnitPrice;
                    row["XRelQty"] = s.XRelQty;

                    row["IUM"] = s.IUM;
                    row["OrderByDate"] = s.OrderByDate;
                    row["DueDate"] = s.DueDate;

                    row["CommentText"] = s.CommentText;
                    row["CheckBox05"] = s.CheckBox05;
                    dt.Rows.Add(row);
                }
                dt.TableName = "Order";
                ds.Tables.Add(dt);
            }
                
            return ds;
        }
    }
}
